import { REQUEST_CONFIG } from "@/data/basic_data";
import { Loading } from "element-ui";

let loadingIns = null;
let num = 0;

export function setUpLoading(config) {
  // if (config[REQUEST_CONFIG.LOADING] === true) {
  num++;
  loadingIns = Loading.service({
    lock: true,
    text: "请稍等",
    spinner: "el-icon-loading",
    background: "rgba(0, 0, 0, 0.7)",
    fullscreen: true
  });
  // }
}

export function uninstallLoading() {
  num--;
  if (loadingIns && !num) {
    loadingIns.close();
    loadingIns = null;
  }
}
